/**
 * 将样式配置，结果维度数据映射关系，数据转换为echart的options
 * @param style
 * @param relativeConfig
 * @param data
 */
function template(title,style,relativeConfig,data){

    let fieldConfig = {x:'',data:[]};





    for(let index in relativeConfig){

        let relationItem = relativeConfig[index];

        if(relationItem.relationDimension == 'x' ){

            fieldConfig.x = relationItem.resultColumn;
        }else if(relationItem.relationDimension == 'data' ){
            fieldConfig.data.push(relationItem.resultColumn);
        }
    }





    let legendData =[];

    let xKey = fieldConfig.x['columnField'];

    let dataKeys = fieldConfig.data;

    let xValues = [];

    let series=[];

    for(let index in dataKeys){

        series.push({
            field:dataKeys[index]['columnField'],
            name:dataKeys[index]['columnDesc'],
            type:'bar',
            data:[]
        });

        legendData.push(dataKeys[index]['columnDesc']);
    }






    for( let index in data){

        let dataitem = data[index];

        xValues.push(dataitem[xKey]);

        for(let sindex in series){

            let serie = series[sindex];

            serie.data.push(dataitem[serie.field]);
        }

    }





    let option = {
        xAxis: {
            type: 'category',
            data:xValues
        },
        yAxis: {
            type: 'value'
        },
        title: {
            text: title
        },
        legend: {
            data:legendData
        },
        series: series,
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
    };

    return option;

}